<template>
  <div class="setcenter_mod" :class="themeClass">
    <v-nav :title="$t('Settings.Settings center')"></v-nav>
    <div class="setcenter_mod_box">
      <div class="setcenter_mod_box_user">
        <van-cell :title="$t('Settings.Nick name')" is-link to="/mine/updatename" :value="userInfo.nickname" />
        <van-cell :title="$t('Settings.account')" :value="userInfo.username" />
        <van-cell :title="$t('Settings.Email address')" :value="userInfo.email" />
      </div>
      <div class="setcenter_mod_box_withdraw">
        <van-cell :title="$t('Settings.Reset security password')" is-link to="/mine/updatefunpwd" />
        <van-cell :title="$t('Settings.Change login password')" is-link to="/mine/updateloginpwd" />
      </div>
      <div class="setcenter_mod_box_langorline">
        <van-cell :title="$t('Settings.switch language')" is-link to="/lang" :value="translate" />
        <van-cell :title="$t('Settings.switch lines')" is-link to="/line" value="lines1" />
      </div>
      <van-button class="signOutBtn" type="danger" round @click="signOut">{{ $t('Settings.sign out') }}</van-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'SetCenter',
  data() {
    return {
      isDayTime: false
    }
  },
  computed: {
    userInfo() {
      return JSON.parse(localStorage.getItem('userInfo'))
    },
    themeClass() {
      return this.isDayTime ? '' : 'darknight'
    },
    translate() {
      var str = ''
      switch (this.$i18n.locale) {
        case 'cn':
          str = '简体中文'
          break
        case 'tw':
          str = '繁體中文'
          break
        case 'ja':
          str = '日本'
          break
        case 'en':
          str = 'English'
          break
        case 'ar':
          str = 'عربي'
          break
        case 'ru':
          str = 'Русский'
          break
        case 'pt':
          str = 'Português'
        case 'es':
          str = 'español'
        case 'ko':
          str = '한국인'
        case 'vi':
          str = 'Tiếng Việt'
        case 'th':
          str = 'แบบไทย'
        case 'id':
          str = 'bahasa Indonesia'
          break
      }
      return str
    }
  },
  watch: {
    '$store.state.nightMode': {
      handler(newVal) {
        this.isDayTime = newVal
      },
      immediate: true
    }
  },
  methods: {
    signOut() {
      localStorage.removeItem('userInfo')
      this.$router.push('/signIn')
    }
  }
}
</script>

<style lang="less" scoped>
@import url('./index.less');
</style>
